
package com.zsrt.day20170420.ch04;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;


public class Test {
	
	@org.junit.Test
	public void hashMapTest() throws Exception {
		
		Map<String, List<Student>> class1704 = new HashMap<String, List<Student>>();
		
		List<Student> students01= new ArrayList<Student>();
		List<Student> students02= new ArrayList<Student>();
		
		Student jmj = new Student("贾梦菊",22);
		Student zsh = new Student("曾少华",30);
		Student zc = new Student("周驰",25);
		Student jzh = new Student("靳志辉",26);
		//Student zjy = new Student("张嘉源 ",21);
		
		students01.add(jmj);
		students01.add(zsh);
		
		students02.add(jzh);
		students02.add(zc);
		
		class1704.put("贾梦菊", students01);
		class1704.put("靳志辉", students02);
		
		List<Student> list = class1704.get("贾梦菊");
		System.out.println(list);
		
		
		//遍历map
		Set<String> keySet = class1704.keySet();
		//其他的直接iterator
		Iterator<String> iterator = keySet.iterator();
		while(iterator.hasNext()){
			String name = iterator.next();
			System.out.println(name);
			
		}
	}

}
